package com.huage_05.util;

import com.huage_05.domain.User;
import org.apache.commons.beanutils.BeanUtils;

import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import java.util.Map;

public class BeanUtilsDemo {
    public static void main(String[] args) {
        Map<String,String> userMap = new HashMap<String,String>();
        userMap.put("name","张三");
        userMap.put("age","23");

        User user = new User();
        try {
            BeanUtils.populate(user,userMap);
            System.out.println(user);
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        }

    }
}
